﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.CMS.MODEL;
using System.Data.SqlClient;

namespace Jxym.wlkc2011
{
    public partial class upOffice : System.Web.UI.Page
    {
        private WebTool.FileUpload.ReturnFileInfo finfo;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Jxym.WebTool.FileUpload.UploadHelper myup = new WebTool.FileUpload.UploadHelper(fileUploadControl, Page);
            myup.AllowExts = ".doc,.docx";
            myup.UpFileUrl = "~/UpFiles/";
            finfo = myup.StartUpload();
            if (finfo.IsOk)
            {
                Label1.Text = finfo.FileServerPath + "<br/>";
                string outPath = Path.ChangeExtension(finfo.FileServerPath, "pdf");
                Jxym.Tools.Converts.OfficeConvert myconvert = new Tools.Converts.OfficeConvert(finfo.FileServerPath, outPath);
                if (myconvert.WordSaveAs(Tools.Converts.OfficeConvert.wdConvertType.wdFormatPDF))
                {
                    Jxym.wlkc2011.pdf2swf mypdf = new pdf2swf(Server.MapPath("~/cmd/pdf2swf.exe"), 9);
                    Label1.Text += mypdf.Start(outPath);
                }
            }
            else
            {
                Label1.Text = finfo.ReturnText;
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            MsSqlDal<Cms_ContentClass> cct = new MsSqlDal<Cms_ContentClass>();
            SqlParameter[] parameters = new SqlParameter[]{
                new SqlParameter("@Title",TextBox6.Text.Trim())
            };
            int count = cct.Updata("Title='" + TextBox5.Text.Trim() + "'", parameters);
            Label2.Text = count > 0 ? "执行成功，更新" + count + "条数据记录" : "执行完毕，没有影响任何数据";
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            MsSqlDal<Cms_Site> cms_Site = new MsSqlDal<Cms_Site>();
            SqlParameter[] parameters = new SqlParameter[]{
                new SqlParameter("@TopInfo",TextBox3.Text.Trim()),
                new SqlParameter("@FootInfo",TextBox4.Text.Trim()),
                new SqlParameter("@Description",TextBox1.Text.Trim()),
                new SqlParameter("@Keyword",TextBox2.Text.Trim())
            };
            int count = cms_Site.Updata("1=1", parameters);
            Label3.Text = count > 0 ? "执行成功，更新" + count + "条数据记录" : "执行完毕，没有影响任何数据";
        }
    }
}